package com.shuai.user.service.inner;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.shuai.common.model.InnerUser;
import com.shuai.common.service.InnerUserService;
import com.shuai.user.domain.entity.User;
import com.shuai.user.service.UserService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author bxs
 * @version 1.0
 * @Date 2024/8/3
 */
@Service
@DubboService
public class InnerUserServiceImpl implements InnerUserService {
    @Autowired
    private UserService userService;

    @Override
    public InnerUser getUserInfo(String apiKey) {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getApiKey, apiKey);
        User one = userService.getOne(queryWrapper);
        InnerUser innerUser = new InnerUser();
        BeanUtils.copyProperties(one, innerUser);
        return innerUser;
    }
}
